﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Southridge.Data;

namespace Southridge.Converters
{
    public class ListingToOneLineAddressConverter : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Listing listing = (value as Listing);


#if SQLCE 
            if (listing != null && listing.Address != null )
            {
                string s = listing.Address.ToOneLine();
                return s;
            }
#else
            if (listing != null)
            {
                string s =
                    listing.Address1 + ", " +
                  listing.City + ", " +
                  listing.State.ID + " " +
                  listing.ZipCode;
                return s;
            }
#endif
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // not implemented
            return null;
        }

        #endregion
    }

}
